import 'package:app_flutter/routes.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';

class TesterPage extends StatefulWidget {
  final int type;

  TesterPage({int type}) : this.type = type;

  @override
  _TesterPageState createState() => _TesterPageState(type: type);
}

class _TesterPageState extends State<TesterPage> {
  int _type;

  List<Map<String, dynamic>> maps = List();
  List<String> items = List();

  _TesterPageState({int type}) : this._type = type;
  List<String> items1 = <String>[
    'A',
    'B',
    'C',
    'D',
    'E',
    'F',
    'G',
    'H',
    'J',
    'A',
    'B',
    'C',
    'D',
    'E',
    'F',
    'G',
    'H',
    'J'
  ];
  List<String> items2 = <String>[
    'Ab',
    'Bb',
    'Cb',
    'Db',
    'Eb',
    'Fb',
  ];
  List<String> items3 = <String>[
    'Ac',
    'Bc',
    'Cc',
    'Dc',
    'Ec',
    'Fc',
    'Gc',
    'Hc',
    'Jc',
    'Ac',
  ];

  List<Widget> doWidgets() {
    setMaps(items);
    List<Widget> listTitles = List();
    for (var i = 0; i < items.length; i++) {
      listTitles.add(buildListItem(context, maps[i]));
    }
    return listTitles;
  }

  Widget buildListItem(BuildContext context, Map<String, dynamic> map) {
    return GestureDetector(
        onTap: () {
          String route = '${Routes.areaDetail}';
          Routes.router.navigateTo(context, route,
              replace: false, transition: TransitionType.fadeIn);
        },
//        child: Column(
//          mainAxisSize: MainAxisSize.max,
//          children: <Widget>[
//            Padding(
//              padding: const EdgeInsets.fromLTRB(0, 17, 0, 17),
//              child: Column(
//                crossAxisAlignment: CrossAxisAlignment.start,
//                mainAxisAlignment: MainAxisAlignment.start,
//                children: <Widget>[
//                  Row(
//                    children: <Widget>[
//                      Text('兴城驾校训练场',
//                          style: TextStyle(
//                              color: Color(0xff333333), fontSize: 14))
//                    ],
//                  ),
//                  Row(
//                    crossAxisAlignment: CrossAxisAlignment.start,
//                    mainAxisSize: MainAxisSize.max,
//                    mainAxisAlignment: MainAxisAlignment.start,
//                    children: <Widget>[
//                      ImageIcon(
//                        AssetImage('images/icon_school.png'),
//                        size: 20,
//                        color: const Color(0xff23AFDC),
//                      ),
//                      SizedBox(
//                        width: 1,
//                      ),
//                      Text('营业$_type',
//                          style: TextStyle(
//                              color: Color(0xff666666), fontSize: 14))
//                    ],
//                  ),
//                ],
//              ),
//            ),
//          ],
//        ));
        child: Row(
          children: <Widget>[
            Image.asset(
              'images/icon_head.png',
              height: 48,
              width: 48,
              fit: BoxFit.fill,
            ),
            SizedBox(
              width: 10,
            ),
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: <Widget>[
                    Text(
                      '白洁',
                      style: TextStyle(color: Colors.black, fontSize: 14),
                    ),
                    SizedBox(
                      width: 6,
                    ),
                    Text(
                      'C1',
                      style: TextStyle(color: Color(0xff23afdc), fontSize: 12),
                    )
                  ],
                ),
                SizedBox(
                  height: 6,
                ),
                Text(
                  '易县世博汽车驾驶员培训学校$_type',
                  style: TextStyle(color: Color(0xff666666), fontSize: 12),
                )
              ],
            ),
          ],
        ));
  }

  @override
  Widget build(BuildContext context) {
    items = items1;
    return Container(
        margin: EdgeInsets.fromLTRB(15, 10, 15, 10),
        child: ListView.separated(
          shrinkWrap: true,
//          physics: NeverScrollableScrollPhysics(),
          itemBuilder: (context, index) => doWidgets()[index],
          separatorBuilder: (context, index) => Divider(
            color: Color(0xffF0F0F0),
          ),
          itemCount: doWidgets().length,
        ));
  }

  setMaps(List<String> items) {
    maps.clear();
    for (var i = 0; i < items.length; i++) {
      Map<String, dynamic> temp = {'title': items[i], 'value': items[i]};
      maps.add(temp);
    }
  }
}
